package com.duomai.myapplication.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.duomai.myapplication.R;
import com.duomai.myapplication.adapter.CostAdapter;
import com.example.admin.SQLite.Complaint;
import com.example.admin.SQLite.SqLiteOpenHelper;
import com.example.admin.SQLite.User;
import com.example.admin.SQLite.dao.feiyongDao;
import com.example.admin.SQLite.feiyong;
import com.example.admin.base.BaseActivity;
import com.example.admin.bean.PersonalBean;
import com.orhanobut.hawk.Hawk;

import java.util.ArrayList;

//费用缴纳
public class CostActivity extends BaseActivity {
    feiyongDao feiyongDaos;
    RecyclerView recyclerView;
    CostAdapter mAdapter;

    @Override
    public void setContentView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_cost);
        recyclerView = findViewById(R.id.recyclerView);
        feiyongDaos = new feiyongDao(this);
        mAdapter = new CostAdapter();
        recyclerView.setAdapter(mAdapter);/*
        mAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
            @Override
            public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
                Complaint bean=mAdapter.getItem(position);
                dbHelper.updateCom(bean.id,"已缴费");
                mAdapter.getItem(position).content="已缴费";
                mAdapter.notifyItemChanged(position);
            }
        });*/
    }

    @Override
    public void setInitView() {

    }

    @Override
    public void onStart() {
        super.onStart();
        getdata();
    }

    private void getdata() {
    /*    ArrayList<Payment> list = dbHelper.getPayment();
        userdapter.setNewData(list);*/
        ArrayList<feiyong> list = feiyongDaos.FindWhereData();
        ArrayList<feiyong> data = new ArrayList<>();
        User user = Hawk.get("user");
        for (feiyong cc : list) {
            Log.e("地方都是", "getdata: "+Hawk.contains("PersonalBean" + user.id) );
            if (Hawk.contains("PersonalBean" + user.id)) {
                PersonalBean bean = Hawk.get("PersonalBean" + user.id);
                Log.e("地方都是", bean.ZZ+"-------: "+cc.feiyongShequ );
                if (TextUtils.equals(bean.ZZ, cc.feiyongShequ)) {
                    if (cc.feiyongHome.equals(user.UserAddress)){
                        data.add(cc);
                    }

                }
            }
        }
        mAdapter.setNewData(data);

    }
}